﻿'********************************************************************************
'*
'*      ＤＢベーク着工/完了履歴　フォーム
'*
'*      File Name : frmStartCompleteDbBake.vb
'*      Title     : ＤＢベーク着工/完了履歴画面
'*      機能    　：ＤＢベーク着工/完了履歴
'*
'********************************************************************************
'----------------------------------<<修正履歴>>----------------------------------
'ﾊﾞｰｼﾞｮﾝ   日付       作業者        ｺﾒﾝﾄ
'--------- ---------- ------------ -----------------------------------------------
' V1.0.0   2016/08/02 S.Yu         新規作成
' V2.0.0   2017/06/16 F.Gotou      蘇州対応
' V3.0.0   2017/12/12 M.Sagawa     北京対応
' V4.0.0   2018/01/09 miao         北京対応
' V5.0.0   2018/02/02 miao         着工成功後、CSVファイルを作成
'********************************************************************************

Imports System.Text


Public Class frmStartCompleteDbBake

    'DBベークサブ画面
    Private frmDbBakeLotStateCheck As frmDbBakeLotStateCheck

    '組立ロットNo.1～24
    Public dtAllLot As New DataTable

    'ラックケースNo
    Dim preRackCaseNo As String = ""
    'ラックNo
    Dim preRackNoData = {"", "", "", "", ""}
    Dim rackNoData = {"", "", "", "", ""}

    '表示用温度
    Dim dbBakeTemp As String = ""
    '表示用時間
    Dim dbBakeTime As String = ""
    '表示用リミットタイム
    Dim dbBakeLimitTimeCode As String = ""
    Dim dbBakeLimitTimeHour As String = ""
    '計算用時間（1ロット目）
    Dim dblDbBakeTime As Double = 0
    '計算用時間（比較対象ロット）
    Dim dblCompDbBakeTime As Double = 0
    '計算用時間（装置条件取得値）
    Dim bakeTime As Double = 0
    '計算用時間形式フォーマット
    Dim reg As New Text.RegularExpressions.Regex("[^0-9]")

    '温度フラグ(完成)
    Dim dbBakeTempFlg As String = "0"
    '温度フラグ(着工)
    Dim dbStartBakeTempFlg As String = "0"

    '製造完成フラグ
    Dim dbBakeCompFlg As String = "0"

    '製造条件フラグ
    Dim bakeEquipFlg As Boolean = False

    '拡散ロットNo
    Dim diffLot As String = ""
    '品名
    Dim prodName As String = ""
    'PB-LAYOUT
    Dim pbLayout As String = ""
    '製品外形
    Dim shape As String = ""

    Dim dtFlows As New DataTable
    Dim dtScreen As DataTable
    Public btnAry As Button()

    '工程コード(ダイボンドベーク)
    Private PROC_CD_A801 As String = "A801"
    '工程コード(モールドベーク)
    Private PROC_CD_A802 As String = "A802"
    '工程コード(メッキベーク)
    Private PROC_CD_A806 As String = "A806"
    '最大ロット数
    Private MAX_LOT_COUNT As Double
    '最大ロット数(ダイボンドベーク)
    'Private MAX_LOT_NUM_A801 As Double = 4 'DEL 苗 2018/3/26
    '最大ロット数(モールドベーク)
    ' Private MAX_LOT_NUM_A802 As Double = 24 'DEL 苗 2018/3/26
    '最大ロット数(メッキベーク)
    'Private MAX_LOT_NUM_A806 As Double = 8 'DEL 苗 2018/3/26
    'ロットの製造条件
    Dim strDbBakeEquipment As String 'ADD 苗 2018/1/12　

    Private Const RACK_NO As String = "RACK NO" 'ADD 苗 2018/1/17　
    Private Const COMP_MS_RACK_NO As String = "COMP MS RACK NO" 'ADD 苗 2018/1/17　

    '>> 2018/2/26 佐川 仕掛情報保存先変更
    'ロット仕掛情報の物理名定義
    Private Const LOT_NO As String = "LOT_NO"
    Private Const SEQ_NO As String = "SEQ_NO"
    Private Const ACTUAL_MODEL As String = "ACTUAL_MODEL"
    '<< 2018/2/26 佐川 仕掛情報保存先変更


    'タブコントロールの設定
    Public Overrides Sub SetTabControl()
        TabPageLot.Enabled = False
        TabPageEqp.Enabled = False
        panelHeader2.Enabled = False

        'ボタン、背景ラベルを配列化
        btnAry = {btnLotDetail1, btnLotDetail2, btnLotDetail3,
                  btnLotDetail4, btnLotDetail5, btnLotDetail6,
                  btnLotDetail7, btnLotDetail8, btnLotDetail9,
                  btnLotDetail10, btnLotDetail11, btnLotDetail12,
                  btnLotDetail13, btnLotDetail14, btnLotDetail15,
                  btnLotDetail16, btnLotDetail17, btnLotDetail18,
                  btnLotDetail19, btnLotDetail20, btnLotDetail21,
                  btnLotDetail22, btnLotDetail23, btnLotDetail24}

        '画面初期化
        InputDataClear()
        loadScreen()
        '不良数初期化
        dgvError.Visible = False
        lblFailedCnt.Text = String.Empty
    End Sub

    '照合結果設定
    Public Overrides Sub SetPassScore()
        PASS_SCORE = 1
        ReDim m_iScore(PASS_SCORE - 1)
        m_iScore = {0}
    End Sub

    'イベント設定
    Public Overrides Sub SetHandler()

        AddHandler txtLot.GotFocus, AddressOf txtBoxGotFocus
        AddHandler txtLot.KeyPress, AddressOf txtLot_KeyPress
        AddHandler txtDbBakeEquipment.GotFocus, AddressOf txtDbBakeEquipment_Focus
        AddHandler txtDbBakeEquipment.KeyPress, AddressOf txtDbBakeEquipment_KeyPress

        '詳細ボタン
        AddHandler btnLotDetail1.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail2.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail3.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail4.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail5.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail6.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail7.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail8.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail9.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail10.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail11.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail12.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail13.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail14.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail15.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail16.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail17.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail18.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail19.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail20.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail21.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail22.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail23.Click, AddressOf btnLotDetail_Click
        AddHandler btnLotDetail24.Click, AddressOf btnLotDetail_Click

        AddHandler btnInputCmpStart.Click, AddressOf btnInputCmpStart_Click
        AddHandler btnInputCmpFin.Click, AddressOf btnInputCmpFin_Click

    End Sub

    ' 組立ロットNo.ボタン押下処理
    Private Sub btnLotTxt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLot.Click
        txtLot.Enabled = True
        txtLot.Focus()
        txtLot.SelectAll()
    End Sub

    'Lot Noでデータベースからデータを取得する
    Public Overrides Sub GetDataByIcTag()
        '初期化
        InputDataLotClear()

        'ロットの設定
        lotNo = txtLot.Text

        'RSB試験対応 入力チェックが別の処理でも複数動いていたため、ここでは処理しない
        '組立ロットNo.入力チェック
        '        If Not CheckLotNo() Then
        '        txtLot.Enabled = True
        '        txtLot.Focus()
        '        txtLot.SelectAll()
        '            Exit Sub
        '        End If

        '条件テーブル取得
        dtJyokenData = m_cData.GetJyokenData(txtLot.Text, m_szProc)
        For Each dr In dtJyokenData.Rows
            If dr(KOMOKUNAME).Equals(lblDbBakeEquipmentConditions.Tag) Then
                dbBakeTemp = dr(KOMOKUDATA)
            ElseIf dr(KOMOKUNAME).Equals(lblDbBakeTime.Tag) Then
                dbBakeTime = dr(KOMOKUDATA)
            ElseIf dr(KOMOKUNAME).Equals(lblLimitTime.Tag + " BASE PROC") Then
                dbBakeLimitTimeCode = dr(KOMOKUDATA)
            ElseIf dr(KOMOKUNAME).Equals(lblLimitTime.Tag + " HOUR") Then
                dbBakeLimitTimeHour = CDbl(dr(KOMOKUDATA))
            ElseIf dr(KOMOKUNAME).Equals(GC_KIND_NM) And
                dr("KOTEI").Equals(GC_LOTINFO) Then
                prodName = dr(KOMOKUDATA)
            ElseIf dr(KOMOKUNAME).Equals(GC_SHAPE) And
                dr("KOTEI").Equals(GC_LOTINFO) Then
                shape = dr(KOMOKUDATA)
            ElseIf dr(KOMOKUNAME).Equals(GC_PB_LAYOUT) And
                dr("KOTEI").Equals(GC_LOTINFO) Then
                pbLayout = dr(KOMOKUDATA)
                'ADD 苗 2018/1/12 BEING ロットの製造条件を取得
            ElseIf dr(KOMOKUNAME).Equals(txtDbBakeEquipment.Tag) Then
                strDbBakeEquipment = dr(KOMOKUDATA)
                'ADD 苗 2018/1/12 BEING 
            End If
        Next

        '前工程のテーブルを取得　maruyama@tmc 2017/7/26
        Dim Pre_Proc_Table As String = ""
        Dim dtPreProc = m_cData.GetPreProcCode(txtLot.Text, lblProcessCD.Text)
        If dtPreProc.Rows.Count > 0 Then
            Pre_Proc_Table = dtPreProc.Rows(0)("PROCTABLE")
            'End If 'DEL MIAO 2018/11/5

            '前工程の計上完成データ取得
            dtPreDetailData = m_cEquipMat.GetPreDetailData(txtLot.Text, TOTAL, Pre_Proc_Table)
            '前工程の計上完成データが存在しなければ、製造完成データを取得する。
            If IsNothing(dtPreDetailData) Then
                dtPreDetailData = m_cEquipMat.GetPreDetailData(txtLot.Text, COMPLETE, Pre_Proc_Table)
            End If
        End If 'ADD MIAO 2018/11/5
        'ADD 苗 2018/1/11 BEGIN
        Dim strRockNo As String = ""

        Select Case lblProcessCD.Text
            Case PROC_CD_A801
                strRockNo = GC_RACK_NO
            Case PROC_CD_A802
                strRockNo = GC_COMP_MS_RACK_NO
            Case PROC_CD_A806
                strRockNo = GC_COMP_MS_RACK_NO
        End Select
        'ADD 苗 2018/1/11 END

        '>>2018/2/2 佐川 キャリア交換対応
        preRackNoData(0) = IcTag.container1
        preRackNoData(1) = IcTag.container2
        preRackNoData(2) = IcTag.container3
        preRackNoData(3) = IcTag.container4
        preRackNoData(4) = IcTag.container5
        'For Each drPreDetail In dtPreDetailData.Rows

        '    'UPD 苗 2018/1/10 GC_RACK_NO⇒strRockNo
        '    If drPreDetail(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG).Equals(strRockNo) Then
        '        If drPreDetail(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1 Then
        '            '前工程 ラックNo1
        '            preRackNoData(0) = drPreDetail(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)
        '        ElseIf drPreDetail(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 2 Then
        '            '前工程 ラックNo2
        '            preRackNoData(1) = drPreDetail(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)
        '        ElseIf drPreDetail(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 3 Then
        '            '前工程 ラックNo3
        '            preRackNoData(2) = drPreDetail(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)
        '        ElseIf drPreDetail(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 4 Then
        '            '前工程 ラックNo4
        '            preRackNoData(3) = drPreDetail(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)
        '        ElseIf drPreDetail(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 5 Then
        '            '前工程 ラックNo5
        '            preRackNoData(4) = drPreDetail(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)
        '        End If
        '    End If
        'Next
        '<<2018/2/2 佐川 キャリア交換対応

        '工程明細テーブル取得、設定
        setDetailData()
        Dim rowsCount As Integer = dtAllLot.Rows.Count
        For Each dr In dtDetailData.Rows
            If dr(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG).Equals("BAKE BSITE SEND") Then
                dbBakeCompFlg = dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)
            ElseIf dr(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG).Equals(strRockNo) Then 'UPD 苗 2018/1/10 GC_RACK_NO⇒strRockNo
                If dr(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1 Then
                    '前工程 ラックNo1
                    rackNoData(0) = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)) 'UPD 苗 2018/10/23
                ElseIf dr(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 2 Then
                    '前工程 ラックNo2
                    rackNoData(1) = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)) 'UPD 苗 2018/10/23
                ElseIf dr(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 3 Then
                    '前工程 ラックNo3
                    rackNoData(2) = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)) 'UPD 苗 2018/10/23
                ElseIf dr(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 4 Then
                    '前工程 ラックNo4
                    rackNoData(3) = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)) 'UPD 苗 2018/10/23
                ElseIf dr(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 5 Then
                    '前工程 ラックNo4
                    rackNoData(4) = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)) 'UPD 苗 2018/10/23
                End If
            End If
        Next

        '工程ヘッダーテーブル取得
        getHeadData()
        If m_dtMat.Rows.Count <= 0 Then
            m_dtMat.Clear()
        End If


    End Sub

    '初期化、背景色（共通）の設定
    Public Sub InputDataLotClear()
        '組立ロットNo.
        txtLot.Enabled = False

        '共通変数の初期化
        preRackCaseNo = ""
        preRackNoData = {"", "", "", "", ""}
        rackNoData = {"", "", "", "", ""}
        dbBakeTemp = ""
        dbBakeTime = ""
        dbBakeLimitTimeCode = ""
        dbBakeLimitTimeHour = ""
    End Sub

    '初期化、背景色の設定
    Public Sub InputDataClear()
        '>> 2018/2/26 佐川 着工中はロット追加不可に修正
        btnLot.Enabled = True
        txtLot.Enabled = True
        '<< 2018/2/26 佐川 着工中はロット追加不可に修正

        '開始　作業者No.
        txtOptNoStt.Text = String.Empty
        '終了　作業者No.
        txtOptNoEnd.Text = String.Empty
        'ステータス更新
        btnStart.Text = getMsgStr("MSG00126")
        btnStart.BackColor = Drawing.SystemColors.Control
        '初期化、背景色（共通）の設定
        InputDataLotClear()
        '組立ロットNo.
        txtLot.Text = String.Empty
        'txtLot.BackColor = NORMAL_INIT_COLOR
        '組立ロットNo.(n)
        dtAllLot.Clear()
        For i = 0 To 23
            Dim btnLotNo As Button
            btnLotNo = txtLot.Parent.Controls.Find(String.Format("btnLotDetail{0}", i + 1), False)(0)
            btnLotNo.Text = getMsgStr("MSG00051")
            btnLotNo.Enabled = False
            btnLotNo.BackColor = BUTTON_INIT_COLOR
            btnLotNo.UseVisualStyleBackColor = True
        Next
        'リミットタイム
        txtLimitTime.Text = String.Empty
        '温度確認ボタン（着工）
        dbStartBakeTempFlg = "0"
        btnStartTempCheck.Text = getMsgStr("MSG00132")
        btnStartTempCheck.BackColor = BUTTON_INIT_COLOR
        btnStartTempCheck.UseVisualStyleBackColor = True
        btnStartTempCheck.Enabled = False
        '温度確認ボタン（完成）
        dbBakeTempFlg = "0"
        btnTempCheck.Text = getMsgStr("MSG00058")
        btnTempCheck.BackColor = BUTTON_INIT_COLOR
        btnTempCheck.UseVisualStyleBackColor = True
        btnTempCheck.Enabled = False
        '着工ボタン
        btnInputCmpStart.Enabled = False
        '完成ボタン
        btnInputCmpFin.Enabled = False

        Select Case lblProcessCD.Text
            Case PROC_CD_A802
                'モールドベーク
                '装置条件に固定値を設定
                txtDbBakeEquipment.Text = "*"
                'dbから温度、時間を取得
                getDbBakeEquipment()
                '装置条件を非活性にする
                txtDbBakeEquipment.Enabled = False
                '最大ロット数設定
                'MAX_LOT_COUNT = max_lot_num_a802 del 苗 2018/3/26

            Case PROC_CD_A806
                'メッキベーク
                '装置条件に固定値を設定
                txtDbBakeEquipment.Text = "*"
                'dbから温度、時間を取得
                getDbBakeEquipment()
                '装置条件を非活性にする
                txtDbBakeEquipment.Enabled = False
                '最大ロット数設定
                'MAX_LOT_COUNT = max_lot_num_a806 del 苗 2018/3/26
            Case PROC_CD_A801
                'ダイボンダベーク
                '最大ロット数設定
                'MAX_LOT_COUNT = max_lot_num_a801 del 苗 2018/3/26
            Case Else
                'レビュー指摘対応表示画面の工程コードがベークでない場合はメッセージを表示する。
                MsgBox(getMsgStr("MSG10010"))
        End Select



    End Sub

    '組立ロットNo.入力チェック
    Protected Function CheckLotNo() As Boolean
        If txtLot.Text.Equals("") Then
            txtLot.BackColor = NORMAL_INIT_COLOR
            Return False
        End If

        '工程一致チェック
        m_fProcessCheck = CheckProcsCD()
        If Not m_fProcessCheck Then
            MsgBox(getMsgStr("MSG00025"))
            txtLot.BackColor = ERROR_INIT_COLOR
            Return False
        End If

        '着工装置チェック
        m_fProcessCheck = CheckEquipID()
        If Not m_fProcessCheck Then
            MsgBox(getMsgStr("MSG00041"))
            txtLot.BackColor = ERROR_INIT_COLOR
            Return False
        End If

        'ロット重複チェック
        For Each dr In dtAllLot.Rows
            If dr(DB_WORK_RESULT_PHYSICALNAME_LOT_NO).Equals(txtLot.Text) Then
                MsgBox(getMsgStr("MSG00079"))
                txtLot.BackColor = ERROR_INIT_COLOR
                Return False
            End If
        Next

        txtLot.BackColor = NORMAL_INIT_COLOR

        Return True
    End Function


    '組立ロットNo.1～24ボタン押下処理
    Private Sub btnLotDetail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If sender.Enabled Then
            Dim frmLotDetai As New frmDbBakeLotStateCheck(Me)
            frmLotDetai.btnName = sender.Name
            frmLotDetai.StartPosition = FormStartPosition.CenterScreen
            '>> 2018/7/19 佐川 ベーク工程不良入力
            '子画面に値を渡す
            frmLotDetai.szLotNo_Bake = IcTag.szLotNo
            frmLotDetai.szProcsCD_Bake = IcTag.szProcsCD
            frmLotDetai.m_szFrameid_comp_Bake = m_szFrameid_comp
            '<< 2018/7/19 佐川 ベーク工程不良入力
            frmLotDetai.ShowDialog()
            'GetDefectCata()
            lotEmptyCheck()
        End If
        '>> 2018/2/26 佐川 サブ画面を閉じた際に組立KeyNoにフォーカスを合わせる
        If IcTag.Status = TagProcessStatus.Ready Then
            txtLot.Enabled = True
            txtLot.Focus()
        End If
        '<< 2018/2/26 佐川 サブ画面を閉じた際に組立KeyNoにフォーカスを合わせる
    End Sub

    '組立KeyNo追加処理
    Private Sub btnAddLotNoAdd()

        Dim lotNoFlg As Boolean = False
        Dim rowsCnt As Integer = dtAllLot.Rows.Count
        Dim btnClick As Button = CType(btnLotDetail1, Button)
        Dim btnInput As Button


        'ロットNoの空白チェック
        lotNoFlg = checkBlank(txtLot.Text, btnLot.Text)
        If Not lotNoFlg Then
            txtLot.BackColor = ERROR_INIT_COLOR
            txtLot.Enabled = True
            txtLot.Focus()
            txtLot.SelectAll()
            Exit Sub
        End If

        '組立KeyNoの入力チェック
        If Not CheckLotNo() Then
            txtLot.Enabled = True
            txtLot.Focus()
            txtLot.SelectAll()

            Exit Sub
        End If

        'リミットタイム設定
        '工程コードから完成日時を取得する
        Dim dt_limitTime = m_cEquipMat.getMaxComplete_Time(txtLot.Text, dbBakeLimitTimeCode)

        Dim limitTime As DateTime
        '完成日時+jyokendataから取得した時間を設定する
        If Not IsNothing(dt_limitTime) Then
            limitTime = CDate(dt_limitTime(0)("COMPLETE_TIME"))
            limitTime = limitTime.AddHours(dbBakeLimitTimeHour)
        End If
        'ロット同一チェック
        If rowsCnt = 0 Then
            '1ロット目の処理
            If Not IcTag.Status = TagProcessStatus.Ready Then
                btnStart.Text = getMsgStr("MSG00119")
                btnStart.BackColor = Color.Lime
            End If

            '1ロット目(温度、時間)ログ出力
            PutLog(Me.ToString, String.Empty,
                   String.Format("１ロット目追加　追加ロットデータ(温度,時間)：{0},{1}", dbBakeTemp, dbBakeTime))

            'ADD 苗 2018/1/17 BEGIN 
            If dbBakeTime.Contains("±") Then 'UPD 苗 2018/1/18 
                Dim stArrayData() As String = Split(dbBakeTime, "±")
                dblDbBakeTime = CDbl(stArrayData(0))
            Else
                Double.TryParse(reg.Replace(dbBakeTime, ""), dblDbBakeTime)
            End If
            'ADD 苗 2018/1/17 BEGIN 

            'Double.TryParse(reg.Replace(dbBakeTime, ""), dblDbBakeTime)'DEL 苗 2018/1/17

            If limitTime > #0:0# Then
                txtLimitTime.Text = limitTime
                '>> 20810322 大賀 No119 ロットのリミットチェックを実施しない
                'If limitTime <= m_cData.GetServerTime() Then
                '    MsgBox(getMsgStr("MSG00115"))
                '    Exit Sub 'ADD 苗 2018/1/18
                'End If
                '<< 20810322 大賀 No119 ロットのリミットチェックを実施しない
            End If


            '工程ヘッダーテーブル取得
            If m_dtMat.Rows.Count > 0 Then
                '開始　作業者No.
                txtOptNoStt.Text = DBNullTOblank(m_dtMat.Rows(0).Item("BEGIN_OPT")) 'UPD 苗 2018/10/23
                '終了　作業者No.
                txtOptNoEnd.Text = DBNullTOblank(m_dtMat.Rows(0).Item("END_OPT")) 'UPD 苗 2018/10/23
            End If
        Else
            '2ロット目以降の処理
            '先頭ロットのステータスを取得
            Dim topLotState As Integer = TagProcessStatus.Ready
            For i = 0 To rowsCnt - 1
                If dtAllLot.Rows(i)("LOT_NO").ToString.Length > 0 Then
                    topLotState = dtAllLot.Rows(i)("LOT_STATE")
                    Exit For
                End If
            Next
            'ステータスチェック
            If topLotState = TagProcessStatus.Ready Then
                '>> 20810322 大賀 No119 ロットのリミットチェックを実施しない
                'リミットタイム超過
                'If limitTime > #0:0# And limitTime <= m_cData.GetServerTime() Then
                '    MsgBox(getMsgStr("MSG00115"))
                '    Exit Sub 'ADD 苗 2018/1/18
                'End If
                '<< 20810322 大賀 No119 ロットのリミットチェックを実施しない
                '着工前の場合
                If Not IcTag.Status = TagProcessStatus.Ready Then
                    lotNoFlg = False
                    MsgBox(getMsgStr("MSG00097"))
                    txtLot.Enabled = True
                    txtLot.Focus()
                    txtLot.SelectAll()
                    Exit Sub
                End If
            Else
                '着工中、製造完成後の場合
                If IcTag.Status = TagProcessStatus.Ready Then
                    lotNoFlg = False
                    MsgBox(getMsgStr("MSG00097"))
                    txtLot.Enabled = True
                    txtLot.Focus()
                    txtLot.SelectAll()
                    Exit Sub
                End If
            End If

            '時間
            Double.TryParse(reg.Replace(dbBakeTime, ""), dblCompDbBakeTime)

        End If
        'DEL 苗 2018/3/26 BEGIN　ロット数チェックは要らない
        'ロット数チェック
        'If rowsCnt >= MAX_LOT_COUNT Then
        '    Dim fullFlg As Boolean = True
        '    空のロットがある場合、データ追加
        '    For i = 0 To rowsCnt - 1
        '        If dtAllLot.Rows(i)("LOT_NO").ToString.Length <= 0 Then
        '            fullFlg = False
        '            Exit For
        '        End If
        '    Next
        '    空のロットがない場合はロット数エラー
        '    If fullFlg Then
        '        lotNoFlg = False
        '        MsgBox(getMsgStr("MSG10001", MAX_LOT_COUNT))
        '        Exit Sub
        '    End If
        'End If
        'DEL 苗 2018/3/26 END　ロット数チェックは要らない

        'ロット追加(温度、時間)ログ出力
        PutLog(Me.ToString, String.Empty,
                   String.Format("ロット追加　追加ロットデータ(温度,時間)：{0},{1} 保持データ(温度,時間)：{2},{3}", dbBakeTemp, dblDbBakeTime, txtDbBakeTemp.Text, bakeTime))
        'UPD 苗 2018/1/9 BEING メッセージ内容変更
        'If Not dbBakeTemp.Equals(txtDbBakeTemp.Text) Then
        '    '温度チェック
        '    lotNoFlg = False
        '    MsgBox(getMsgStr("MSG10007", lblDbBakeEquipmentConditions.Text))
        '    txtLot.Enabled = True
        '    txtLot.Focus()
        '    txtLot.SelectAll()
        '    Exit Sub
        'ElseIf Not dblDbBakeTime.Equals(bakeTime) Then
        '    '時間チェック
        '    lotNoFlg = False
        '    MsgBox(getMsgStr("MSG10008", lblDbBakeTime.Text))
        '    txtLot.Enabled = True
        '    txtLot.Focus()
        '    txtLot.SelectAll()
        '    Exit Sub
        'End If
        'UPD 苗 2018/1/12 BEING A801の場合、Lotの製造条件も判断する必要
        If lblProcessCD.Text.Equals(PROC_CD_A801) Then
            If strDbBakeEquipment.Equals(txtDbBakeEquipment.Text) = False Then 'UPD 苗 2018/1/16 
                MsgBox(getMsgStr("MSG10015"))
                txtLot.Enabled = True
                txtLot.Focus()
                txtLot.SelectAll()
                Exit Sub
            End If
        End If
        'UPD 苗 2018/1/12 END

        If Not dbBakeTemp.Equals(txtDbBakeTemp.Text) OrElse Not dblDbBakeTime.Equals(bakeTime) Then
            MsgBox(getMsgStr("MSG10015"))
            txtLot.Enabled = True
            txtLot.Focus()
            txtLot.SelectAll()
            Exit Sub
        End If


        'UPD 苗 2018/1/9 END メッセージ内容変更
        If lotNoFlg Then
            'データ詰め込み
            If dtAllLot.Columns.Count = 0 Then
                '列追加
                dtAllLot.Columns.Add("LOT_NO")
                dtAllLot.Columns.Add("WAFERLOT_NO")
                dtAllLot.Columns.Add("EQP_NO")
                dtAllLot.Columns.Add("PROCESS_CD")
                dtAllLot.Columns.Add("RACK_NO_1")
                dtAllLot.Columns.Add("RACK_NO_2")
                dtAllLot.Columns.Add("RACK_NO_3")
                dtAllLot.Columns.Add("RACK_NO_4")
                dtAllLot.Columns.Add("RACK_NO_5")
                dtAllLot.Columns.Add("PRE_RACK_NO_1")
                dtAllLot.Columns.Add("PRE_RACK_NO_2")
                dtAllLot.Columns.Add("PRE_RACK_NO_3")
                dtAllLot.Columns.Add("PRE_RACK_NO_4")
                dtAllLot.Columns.Add("PRE_RACK_NO_5")
                dtAllLot.Columns.Add("PROD_NAME")
                dtAllLot.Columns.Add("DIFF_LOT")
                dtAllLot.Columns.Add("PB_LAYOUT")
                dtAllLot.Columns.Add("SHAPE")
                dtAllLot.Columns.Add("INV_NUM")
                dtAllLot.Columns.Add("COMPLETE_NUM")
                dtAllLot.Columns.Add("FRAME_NUM")
                dtAllLot.Columns.Add("FAILD_NUM")
                dtAllLot.Columns.Add("PRE_COMPLETE_NUM")
                dtAllLot.Columns.Add("PRE_FRAME_NUM")
                dtAllLot.Columns.Add("PRE_FAILD_NUM")
                dtAllLot.Columns.Add("BAD_MARK_NUM")
                dtAllLot.Columns.Add("PRE_BAD_MARK_NUM")
                dtAllLot.Columns.Add("PRE_BAD_MARK_FRMNUM")
                dtAllLot.Columns.Add("BAD_MARK_FRMNUM")
                dtAllLot.Columns.Add("Q_FLAG")
                dtAllLot.Columns.Add("TEST_FLAG")
                dtAllLot.Columns.Add("CHECK_FLAG")
                dtAllLot.Columns.Add("RESULT")
                dtAllLot.Columns.Add("COMP_TYPE")
                dtAllLot.Columns.Add("LOT_STATE", Type.GetType("System.Int32"))
                dtAllLot.Columns.Add("NEXT_PROC_CD")
                '>> 2018/7/19 佐川 ベーク工程不良入力
                '空チップ数の保存領域追加
                dtAllLot.Columns.Add("EMPTY_CHIP_NUM")
                '<< 2018/7/19 佐川 ベーク工程不良入力

            End If

            Dim count As Integer = 0
            Dim inputFlg As Boolean = False

            '空きチェック
            For Each dr In dtAllLot.Rows
                If String.IsNullOrEmpty(dr("LOT_NO")) Then
                    inputDataLot(count)
                    inputFlg = True
                    btnInput = btnClick.Parent.Controls.Find(String.Format("btnLotDetail{0}", count + 1), False)(0)
                    btnInput.Text = txtLot.Text + vbCrLf + " "
                    btnInput.Enabled = True
                    Exit For
                End If
                count += 1
            Next

            '空きがない場合は一番後ろに追加
            If Not inputFlg Then
                dtAllLot.Rows.Add()
                inputDataLot(rowsCnt)
                btnInput = btnClick.Parent.Controls.Find(String.Format("btnLotDetail{0}", rowsCnt + 1), False)(0)
                btnInput.Text = txtLot.Text + vbCrLf + " "
                btnInput.Enabled = True
            End If

            '着工ボタンの制御
            If dtAllLot.Rows.Count = 1 And IcTag.Status = TagProcessStatus.Ready Then
                btnInputCmpStart.Enabled = True
                btnStartTempCheck.Enabled = True
                btnTempCheck.Enabled = False
            ElseIf dtAllLot.Rows.Count = 1 And Not IcTag.Status = TagProcessStatus.Ready Then
                btnInputCmpStart.Enabled = False
                btnStartTempCheck.Text = getMsgStr("MSG00133")
                btnStartTempCheck.BackColor = ENTERED_INIT_COLOR
                btnStartTempCheck.Enabled = False
                btnTempCheck.Enabled = True
            End If

            '入力欄のクリア
            txtLot.Text = String.Empty
            txtLot.Focus()

        End If
    End Sub


    '温度確認ボタン押下処理(完成)
    Private Sub btnTempCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTempCheck.Click
        If btnTempCheck.Text.Equals(getMsgStr("MSG00058")) Then
            btnTempCheck.Text = getMsgStr("MSG00059")
            btnTempCheck.BackColor = ENTERED_INIT_COLOR
            dbBakeTempFlg = "1"
            '完成ボタンを押下可能にする。
            btnInputCmpFin.Enabled = True
        Else
            btnTempCheck.Text = getMsgStr("MSG00058")
            btnTempCheck.BackColor = BUTTON_INIT_COLOR
            btnTempCheck.UseVisualStyleBackColor = True
            dbBakeTempFlg = "0"
            '完成ボタンを押下不可能にする。
            btnInputCmpFin.Enabled = False
        End If
    End Sub

    '温度確認ボタン押下処理(着工)
    Private Sub btnStartTempCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartTempCheck.Click
        If btnStartTempCheck.Text.Equals(getMsgStr("MSG00132")) Then
            btnStartTempCheck.Text = getMsgStr("MSG00133")
            btnStartTempCheck.BackColor = ENTERED_INIT_COLOR
            dbStartBakeTempFlg = "1"
        Else
            btnStartTempCheck.Text = getMsgStr("MSG00132")
            btnStartTempCheck.BackColor = BUTTON_INIT_COLOR
            btnStartTempCheck.UseVisualStyleBackColor = True
            dbStartBakeTempFlg = "0"
        End If
    End Sub

    ' 着工ボタン押下処理
    Protected Sub btnInputCmpStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Dim checkFlg As Boolean = True
        Dim btnLotNo As Button

        '開始作業者No入力チェック
        If txtOptNoStt.TextLength <= 0 Then
            MsgBox(getMsgStr("MSG00015", btnOptNoStt.Text))
            Exit Sub
        End If

        '温度フラグチェック
        If dbStartBakeTempFlg = 0 Then
            MsgBox(getMsgStr("MSG00014", lblDbBakeEquipmentConditions.Text))
            Exit Sub
        End If

        For i = 0 To dtAllLot.Rows.Count - 1
            'ロットがない場合はスキップ
            If dtAllLot.Rows(i)("LOT_NO").ToString.Length <= 0 Then
                Continue For
            End If

            Dim frmLotDetai As New frmDbBakeLotStateCheck(Me)

            '空白チェック
            If dtAllLot.Rows(i)("RACK_NO_1").ToString.Length <= 0 Then
                MsgBox(getMsgStr("MSG00094", btnLot.Text + (i + 1).ToString, frmLotDetai.lblRackNo1.Text))
                Exit Sub
            End If

            '前工程ラックNoの数を取得
            Dim preRackCount As Integer = 0
            Dim preRackArray = {"", "", "", "", ""}
            For j = 1 To 5
                Dim preRackNo As String = dtAllLot.Rows(i)("PRE_RACK_NO_" + j.ToString).ToString
                If preRackNo.Length > 0 AndAlso Not DELETE_RACK_NO.Equals(preRackNo) Then
                    preRackArray(preRackCount) = preRackNo
                    preRackCount += 1
                End If
            Next

            '前工程一致チェック
            For j = 1 To preRackCount
                checkFlg = chkPreRackNo(dtAllLot, i, j, preRackCount, preRackArray)
                If Not checkFlg Then
                    'Dim lblName As String = frmLotDetai.btnRackNo.Text + j.ToString
                    MsgBox(getMsgStr("MSG00093", btnLot.Text + (i + 1).ToString, ""))
                    Exit Sub
                End If
            Next

            'ラックNo全削除チェック
            checkFlg = chkDelRackNo(dtAllLot, i)
            If Not checkFlg Then
                'Dim lblName As String = frmLotDetai.btnRackNo.Text + i.ToString
                MsgBox(getMsgStr("MSG00136", btnLot.Text + (i + 1).ToString, ""))
                Exit Sub
            End If
        Next

        Me.Cursor = Cursors.WaitCursor
        bakeWorkStart(dtAllLot)
        Me.Cursor = Cursors.Default

        ' B-Siteエラーの場合は組立ロット詳細情報「結果」に表示
        Dim errorCount As Integer = 0
        For i = 0 To dtAllLot.Rows.Count - 1
            'ロットがない場合はスキップ
            If dtAllLot.Rows(i)("LOT_NO").ToString.Length <= 0 Then
                Continue For
            End If
            btnLotNo = sender.Parent.Controls.Find(String.Format("btnLotDetail{0}", i + 1), False)(0)
            If dtAllLot.Rows(i)("RESULT").ToString.Equals("NG") Then
                btnLotNo.Text = dtAllLot.Rows(i)("LOT_NO").ToString + getMsgStr("MSG00087")
                errorCount += 1
            Else
                btnLotNo.Text = dtAllLot.Rows(i)("LOT_NO").ToString & vbCrLf & " "
            End If
        Next

        If outHeader.Status <> STS_SUCCESS Then
            btnStart.Text = getMsgStr("MSG00123")
            btnStart.BackColor = Color.LightCoral
            Exit Sub
        Else
            saveScreen()
            ' B-Siteエラーがない場合は組立ロット詳細情報「結果」は空白
            For Each dr In dtAllLot.Rows
                dr("RESULT") = String.Empty
                dr("COMP_TYPE") = "3"
                dr("LOT_STATE") = TagProcessStatus.Processing
                dr("PRE_RACK_NO_1") = dr("RACK_NO_1")
                dr("PRE_RACK_NO_2") = dr("RACK_NO_2")
                dr("PRE_RACK_NO_3") = dr("RACK_NO_3")
                dr("PRE_RACK_NO_4") = dr("RACK_NO_4")
                dr("PRE_RACK_NO_5") = dr("RACK_NO_5")
            Next
            btnInputCmpStart.Enabled = False
            btnStartTempCheck.Enabled = False
            btnTempCheck.Enabled = True
            btnStart.Text = getMsgStr("MSG00119")
            btnStart.BackColor = Color.Lime
            '温度確認ボタン（着工）
            dbStartBakeTempFlg = "0"
            'btnStartTempCheck.Text = getMsgStr("MSG00132")
            'btnStartTempCheck.BackColor = BUTTON_INIT_COLOR
            'btnStartTempCheck.UseVisualStyleBackColor = True
            'btnStartTempCheck.Enabled = False

            '>> 2018/2/26 佐川 着工中はロット追加不可に修正
            btnLot.Enabled = False
            txtLot.Enabled = False
            txtLot.BackColor = NORMAL_INIT_COLOR
            txtDbBakeEquipment.BackColor = NORMAL_INIT_COLOR
            '<< 2018/2/26 佐川 着工中はロット追加不可に修正 
        End If

        'ADD 苗 2018/2/2 BEGIN
        Try
            Dim strDirectory As String = Application.StartupPath & "\Cure" 'ディレクトリ
            Dim strFile As String = Application.StartupPath & "\Cure\" & System.DateTime.Now.ToString("yyyyMMddhhmmss") & ".csv" 'ファイル名
            Dim strCSV As String 'CSFファイルの内容

            'ディレクトリが存在チェック
            If Not My.Computer.FileSystem.DirectoryExists(strDirectory) Then
                My.Computer.FileSystem.CreateDirectory(strDirectory)
            End If
            '内容：装置No,ロット１のKey NO,温度,時間
            strCSV = g_EQUIP_NO & "," & btnLotDetail1.Text.Trim & "," & txtDbBakeTemp.Text & "," & txtDbBakeTime.Text
            My.Computer.FileSystem.WriteAllBytes(strFile, System.Text.Encoding.Default.GetBytes(strCSV), False)

        Catch
            MsgBox(getMsgStr("MSG10022")) 'UPD 苗 2018/2/7 メッセージID変更
        End Try
        'ADD 苗 2018/2/2 END
        '着工時(温度、時間)ログ出力
        PutLog(Me.ToString, String.Empty,
                   String.Format("着工　ロットデータ(温度,時間)：{0},{1}", dbBakeTemp, dblDbBakeTime))

    End Sub

    ' 完成ボタン押下処理
    Protected Sub btnInputCmpFin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Dim compNum As Integer
        Dim preCompNum As Integer
        Dim checkFlg As Boolean = True
        Dim btnLotNo As Button
        Dim m_dtBeginTime As New DataTable
        'DEL 苗 2018/1/25 BEGIN
        'Dim lastChakukouTime As DateTime
        'Dim bakeTime As TimeSpan
        'DEL 苗 2018/1/25 END
        Dim currentTime As DateTime = m_cData.GetServerTime()

        '終了作業者No入力チェック
        If txtOptNoEnd.TextLength <= 0 Then
            MsgBox(getMsgStr("MSG00015", btnOptNoEnd.Text))
            Exit Sub
        End If

        '温度フラグチェック
        If dbBakeTempFlg = 0 Then
            MsgBox(getMsgStr("MSG00014", lblDbBakeEquipmentConditions.Text))
            Exit Sub
        End If

        'DEL 苗 2018/1/25 BEGIN RSB対応：経過時間が不要
        ''経過時間チェック
        'For i = 0 To dtAllLot.Rows.Count - 1
        '    If dtAllLot.Rows(i)("LOT_NO").ToString.Length <= 0 Then
        '        Continue For
        '    End If

        '    '前回着工時間取得
        '    m_dtBeginTime = m_cEquipMat.GetResultHead(dtAllLot.Rows(i)("LOT_NO").ToString, BEGIN, lblProcessCD.Text)
        '    If m_dtBeginTime.Rows.Count > 0 Then
        '        lastChakukouTime = m_dtBeginTime.Rows(0).Item("BEGIN_TIME")
        '    End If

        '    Exit For
        'Next

        'bakeTime = currentTime.Subtract(lastChakukouTime)

        'If bakeTime.TotalMinutes < dblDbBakeTime Then
        '    MsgBox(getMsgStr("MSG00134"))
        '    Exit Sub
        'End If
        'DEL 苗 2018/1/25 END
        Dim strOptNoEnd = txtOptNoEnd.Text
        'DEL MIAO 2018/7/12 BEGIN
        'dtAllLot.Clear() 'ADD 苗 2018/4/19
        'loadScreen() 'ADD 苗 2018/4/19
        'DEL MIAO 2018/7/12 END

        txtOptNoEnd.Text = strOptNoEnd
        For i = 0 To dtAllLot.Rows.Count - 1
            If dtAllLot.Rows(i)("LOT_NO").ToString.Length <= 0 Then
                Continue For
            End If

            '完工時数量チェック
            compNum = Integer.Parse(dtAllLot.Rows(i)("COMPLETE_NUM")) + Integer.Parse(dtAllLot.Rows(i)("FAILD_NUM"))
            preCompNum = Integer.Parse(dtAllLot.Rows(i)("INV_NUM"))
            If Not compNum = preCompNum Then
                MsgBox(getMsgStr("MSG00100", btnLot.Text + (i + 1).ToString))
                Exit Sub
            End If

            If dtAllLot.Rows(i)("LOT_NO").ToString.Length <= 0 Then
                Continue For
            End If

            Dim frmLotDetai As New frmDbBakeLotStateCheck(Me)

            '空白チェック
            If dtAllLot.Rows(i)("RACK_NO_1").ToString.Length <= 0 Then
                MsgBox(getMsgStr("MSG00094", btnLot.Text + (i + 1).ToString, frmLotDetai.lblRackNo1.Text))
                Exit Sub
            End If

            '前工程ラックNoの数を取得
            Dim preRackCount As Integer = 0
            Dim preRackArray = {"", "", "", "", ""}
            For j = 1 To 5
                Dim preRackNo As String = dtAllLot.Rows(i)("PRE_RACK_NO_" + j.ToString).ToString
                If preRackNo.Length > 0 AndAlso Not DELETE_RACK_NO.Equals(preRackNo) Then
                    preRackArray(preRackCount) = preRackNo
                    preRackCount += 1
                End If
            Next

            '前工程一致チェック
            For j = 1 To preRackCount
                checkFlg = chkPreRackNo(dtAllLot, i, j, preRackCount, preRackArray)
                If Not checkFlg Then
                    'Dim lblName As String = frmLotDetai.btnRackNo.Text + j.ToString
                    MsgBox(getMsgStr("MSG00096", btnLot.Text + (i + 1).ToString, ""))
                    Exit Sub
                End If
            Next

            'ラックNo全削除チェック
            checkFlg = chkDelRackNo(dtAllLot, i)
            If Not checkFlg Then
                'Dim lblName As String = frmLotDetai.btnRackNo.Text + i.ToString
                MsgBox(getMsgStr("MSG00136", btnLot.Text + (i + 1).ToString, ""))
                Exit Sub
            End If
        Next

        Me.Cursor = Cursors.WaitCursor
        bakeWorkFinish(dtAllLot)
        Me.Cursor = Cursors.Default

        ' B-Siteエラーの場合は組立ロット詳細情報「結果」に表示
        For i = 0 To dtAllLot.Rows.Count - 1
            'ロットがない場合はスキップ
            If dtAllLot.Rows(i)("LOT_NO").ToString.Length <= 0 Then
                Continue For
            End If

            btnLotNo = sender.Parent.Controls.Find(String.Format("btnLotDetail{0}", i + 1), False)(0)

            If bsiteSuccessFlag Then
                If dtAllLot.Rows(i)("COMP_TYPE").ToString.Equals(COMPLETE) Then
                    'ステータスを更新
                    dtAllLot.Rows(i)("LOT_STATE") = TagProcessStatus.ManufComplete
                    '製造完成フラグの設定
                    dtAllLot.Rows(i)("COMP_TYPE") = TOTAL
                End If
            Else
                If dtAllLot.Rows(i)("RESULT").ToString.Equals("NG") Then
                    '計上完成の場合
                    If dtAllLot.Rows(i)("COMP_TYPE").ToString.Equals(TOTAL) Then
                        btnLotNo.Text = dtAllLot.Rows(i)("LOT_NO").ToString + getMsgStr("MSG00088")

                        Dim manufComp As DataTable = m_cEquipMat.getBakeManufCompData(dtAllLot.Rows(i)("LOT_NO"), lblProcessCD.Text)
                        If Integer.Parse(manufComp.Rows(0)("COUNT")) > 0 Then
                            dtAllLot.Rows(i)("COMP_TYPE") = TOTAL
                        Else
                            'dtAllLot.Rows(i)("COMP_TYPE") = COMPLETE 'DEL 苗 2018/4/12 製造完成ボタンがないため、削除する
                        End If
                    End If

                Else
                    btnLotNo.Text = dtAllLot.Rows(i)("LOT_NO").ToString & vbCrLf & " "
                End If
            End If
        Next

        '完成時(温度、時間)ログ出力
        PutLog(Me.ToString, String.Empty,
                   String.Format("完成　ロットデータ(温度,時間)：{0},{1}", dbBakeTemp, dblDbBakeTime))

        ' B-Siteエラーがない場合は画面初期化
        If bsiteSuccessFlag Then
            saveCompScreen()
            InputDataClear()
            'ステータス更新
            btnStart.Text = getMsgStr("MSG00126")
            btnStart.BackColor = Drawing.SystemColors.Control

            txtLot.Enabled = True
            txtLot.Focus()
            Button1.Enabled = False '20180227 佐川 着工待ちはマーク図押下不可対応
        Else
            'ステータス更新
            btnStart.Text = getMsgStr("MSG00123")
            btnStart.BackColor = Color.LightCoral
        End If

    End Sub

    '画面データ保存（着工時）
    Public Overrides Function SaveEquipMat(ByRef szBeginTime As DateTime) As Boolean
        If saveDetail(BEGIN) < 0 Then
            Return False
        Else
            Return True
        End If

        Return True
    End Function

    '画面データ保存（完成）
    Public Overrides Function SaveTotalInfo() As Integer
        dtDBUpd.Clear()
        Return saveDetail(TOTAL)
    End Function


    Private Sub inputDataLot(ByVal rowsCnt As Integer)
        dtAllLot.Rows(rowsCnt)("LOT_NO") = txtLot.Text
        dtAllLot.Rows(rowsCnt)("WAFERLOT_NO") = IcTag.szDifLotNo
        dtAllLot.Rows(rowsCnt)("EQP_NO") = IcTag.szEquipID
        dtAllLot.Rows(rowsCnt)("PROCESS_CD") = IcTag.szProcsCD
        If IcTag.Status = TagProcessStatus.Ready Then
            dtAllLot.Rows(rowsCnt)("RACK_NO_1") = preRackNoData(0)
            dtAllLot.Rows(rowsCnt)("RACK_NO_2") = preRackNoData(1)
            dtAllLot.Rows(rowsCnt)("RACK_NO_3") = preRackNoData(2)
            dtAllLot.Rows(rowsCnt)("RACK_NO_4") = preRackNoData(3)
            dtAllLot.Rows(rowsCnt)("RACK_NO_5") = preRackNoData(4)
            dtAllLot.Rows(rowsCnt)("PRE_RACK_NO_1") = preRackNoData(0)
            dtAllLot.Rows(rowsCnt)("PRE_RACK_NO_2") = preRackNoData(1)
            dtAllLot.Rows(rowsCnt)("PRE_RACK_NO_3") = preRackNoData(2)
            dtAllLot.Rows(rowsCnt)("PRE_RACK_NO_4") = preRackNoData(3)
            dtAllLot.Rows(rowsCnt)("PRE_RACK_NO_5") = preRackNoData(4)
        Else
            dtAllLot.Rows(rowsCnt)("RACK_NO_1") = rackNoData(0)
            dtAllLot.Rows(rowsCnt)("RACK_NO_2") = rackNoData(1)
            dtAllLot.Rows(rowsCnt)("RACK_NO_3") = rackNoData(2)
            dtAllLot.Rows(rowsCnt)("RACK_NO_4") = rackNoData(3)
            dtAllLot.Rows(rowsCnt)("RACK_NO_5") = rackNoData(4)
            dtAllLot.Rows(rowsCnt)("PRE_RACK_NO_1") = rackNoData(0)
            dtAllLot.Rows(rowsCnt)("PRE_RACK_NO_2") = rackNoData(1)
            dtAllLot.Rows(rowsCnt)("PRE_RACK_NO_3") = rackNoData(2)
            dtAllLot.Rows(rowsCnt)("PRE_RACK_NO_4") = rackNoData(3)
            dtAllLot.Rows(rowsCnt)("PRE_RACK_NO_5") = rackNoData(4)
        End If
        dtAllLot.Rows(rowsCnt)("PROD_NAME") = prodName
        dtAllLot.Rows(rowsCnt)("DIFF_LOT") = IcTag.szDifLotNo
        dtAllLot.Rows(rowsCnt)("PB_LAYOUT") = pbLayout
        dtAllLot.Rows(rowsCnt)("SHAPE") = shape
        dtAllLot.Rows(rowsCnt)("INV_NUM") = IcTag.iInput
        dtAllLot.Rows(rowsCnt)("COMPLETE_NUM") = IcTag.iFinish
        dtAllLot.Rows(rowsCnt)("FRAME_NUM") = IcTag.iFrame
        dtAllLot.Rows(rowsCnt)("FAILD_NUM") = "0"
        dtAllLot.Rows(rowsCnt)("PRE_COMPLETE_NUM") = IcTag.iFinish
        dtAllLot.Rows(rowsCnt)("PRE_FRAME_NUM") = IcTag.iFrame
        dtAllLot.Rows(rowsCnt)("PRE_FAILD_NUM") = IcTag.iFailed
        dtAllLot.Rows(rowsCnt)("BAD_MARK_NUM") = IcTag.iCross
        dtAllLot.Rows(rowsCnt)("PRE_BAD_MARK_NUM") = IcTag.iCross
        dtAllLot.Rows(rowsCnt)("BAD_MARK_FRMNUM") = IcTag.iCrossFrm
        dtAllLot.Rows(rowsCnt)("PRE_BAD_MARK_FRMNUM") = IcTag.iCrossFrm
        dtAllLot.Rows(rowsCnt)("Q_FLAG") = IcTag.fQflag
        dtAllLot.Rows(rowsCnt)("TEST_FLAG") = IcTag.fTestflag
        dtAllLot.Rows(rowsCnt)("CHECK_FLAG") = IcTag.fCheckflag
        dtAllLot.Rows(rowsCnt)("LOT_STATE") = IcTag.Status
        '>> 2018/7/19 佐川 ベーク工程不良入力
        '空チップ数を保存する。
        dtAllLot.Rows(rowsCnt)("EMPTY_CHIP_NUM") = IcTag.emptyChipNum
        '<< 2018/7/19 佐川 ベーク工程不良入力
        If IcTag.Status = TagProcessStatus.Ready Then
            dtAllLot.Rows(rowsCnt)("COMP_TYPE") = BEGIN
        Else
            dtAllLot.Rows(rowsCnt)("COMP_TYPE") = TOTAL
        End If

    End Sub

    Private Function saveDetail(ByVal type As String) As Integer

        Dim result As Integer
        Dim rowsCnt As Integer = 0
        Dim strRackNo As String 'ADD 苗 2018/1/17
        Dim addIndex As Integer = 0

        ' 組立ロットNo.1～24のデータセット
        For i = 0 To dtAllLot.Rows.Count - 1
            result = 0
            dtDBUpd.Clear()
            m_dtHeader.Clear()
            addIndex = 0

            m_dtHeader = m_cEquipMat.GetHeader(dtAllLot.Rows(i)("LOT_NO").ToString, g_EQUIP_NO, lblProcessCD.Text, DateTime.Now.ToString(DATE_TIME_FORMAT_DB)) 'UPD 苗 2018/1/19 装置No.の対応
            If m_dtHeader.Rows.Count <= 0 Then
                m_dtHeader.Rows.Add()
            End If

            'ロットがない場合はスキップ
            If dtAllLot.Rows(i)("LOT_NO").ToString.Length <= 0 Then
                Continue For
            End If

            'ヘッダの保存
            SaveBakeHeader(serverTime.ToString(DATE_TIME_FORMAT_DB), dtAllLot.Rows(i))

            '製造完成を指定した場合
            If type <> BEGIN Then
                If dtAllLot.Rows(i)("COMP_TYPE").ToString.Equals("2") Then
                    type = COMPLETE
                ElseIf dtAllLot.Rows(i)("COMP_TYPE").ToString.Equals("3") Then
                    type = TOTAL
                End If
            End If

            Dim frmLotDetai As New frmDbBakeLotStateCheck(Me)
            rowsCnt = dtDBUpd.Rows.Count

            ' リミットタイム
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lblLimitTime.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 0
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txtLimitTime.Text
            addIndex += 1

            ' 製造条件
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = txtDbBakeEquipment.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 0
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txtDbBakeEquipment.Text
            addIndex += 1

            ' 温度
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lblDbBakeEquipmentConditions.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 1
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txtDbBakeTemp.Text
            addIndex += 1

            ' 時間
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lblDbBakeTime.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 1
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txtDbBakeTime.Text
            addIndex += 1

            'ADD 苗 2018/1/17 BEGIN
            If lblProcessCD.Text.Equals(PROC_CD_A801) Then
                strRackNo = RACK_NO
            Else
                strRackNo = COMP_MS_RACK_NO
            End If
            'ADD 苗 2018/1/17 END
            ' ラックNo.1
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = strRackNo 'ADD 苗 2018/1/17
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 0
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = dtAllLot.Rows(i)("RACK_NO_1").ToString
            addIndex += 1

            ' ラックNo.2
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = strRackNo 'ADD 苗 2018/1/17
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 0
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 2
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = dtAllLot.Rows(i)("RACK_NO_2").ToString
            addIndex += 1

            ' ラックNo.3
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = strRackNo 'ADD 苗 2018/1/17
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 0
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 3
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = dtAllLot.Rows(i)("RACK_NO_3").ToString
            addIndex += 1

            ' ラックNo.4
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = strRackNo 'ADD 苗 2018/1/17
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 0
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 4
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = dtAllLot.Rows(i)("RACK_NO_4").ToString
            addIndex += 1

            ' ラックNo.5
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = strRackNo 'ADD 苗 2018/1/17
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 0
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 5
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = dtAllLot.Rows(i)("RACK_NO_5").ToString
            addIndex += 1

            ' 結果
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = frmLotDetai.lblResult.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 0
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = dtAllLot.Rows(i)("RESULT").ToString
            addIndex += 1

            result = m_cEquipMat.SaveDetail(dtAllLot.Rows(i)("LOT_NO").ToString, dtAllLot.Rows(i)("PROCESS_CD").ToString, type,
                                    m_szTable, dtDBUpd, m_dtHeader,
                                    m_cIdohyo.EquipInfo.szEquipNo, serverTime)
            If result < 0 Then
                Exit For
            End If

            '組立ロットNo.
            LastTag.szLotNo = dtAllLot.Rows(i)("LOT_NO").ToString
            '拡散ロットNo.
            LastTag.szDifLotNo = dtAllLot.Rows(i)("WAFERLOT_NO").ToString

            '装置No、工程コード
            If dtAllLot.Rows(i)("LOT_STATE") = TagProcessStatus.Ready Then
                LastTag.szEquipID = g_EQUIP_NO 'UPD 苗 2018/1/19 装置No.の対応
                LastTag.szProcsCD = dtAllLot.Rows(i)("PROCESS_CD").ToString
            ElseIf dtAllLot.Rows(i)("LOT_STATE") = TagProcessStatus.Processing Then
                If dtAllLot.Rows(i)("COMP_TYPE").ToString.Equals(COMPLETE) Then
                    LastTag.szEquipID = g_EQUIP_NO 'UPD 苗 2018/1/19 装置No.の対応
                    LastTag.szProcsCD = dtAllLot.Rows(i)("PROCESS_CD").ToString
                Else
                    LastTag.szEquipID = ""
                    LastTag.szProcsCD = dtAllLot.Rows(i)("NEXT_PROC_CD")
                End If
            End If

            '投入数
            If dtAllLot.Rows(i)("LOT_STATE") = TagProcessStatus.Ready Then
                LastTag.iInput = Integer.Parse(dtAllLot.Rows(i)("COMPLETE_NUM"))
                dtAllLot.Rows(i)("INV_NUM") = dtAllLot.Rows(i)("COMPLETE_NUM")
            Else
                LastTag.iInput = Integer.Parse(dtAllLot.Rows(i)("INV_NUM"))
            End If

            If dtAllLot.Rows(i)("LOT_STATE") = TagProcessStatus.ManufComplete OrElse
                (dtAllLot.Rows(i)("LOT_STATE") = TagProcessStatus.Processing And
                dtAllLot.Rows(i)("COMP_TYPE") = TOTAL) Then
                '完成数
                LastTag.iFinish = Integer.Parse(dtAllLot.Rows(i)("COMPLETE_NUM"))
                '枚数
                LastTag.iFrame = Integer.Parse(dtAllLot.Rows(i)("FRAME_NUM"))
                '不良数
                LastTag.iFailed = Integer.Parse(dtAllLot.Rows(i)("FAILD_NUM"))

            Else
                '完成数
                LastTag.iFinish = Integer.Parse(dtAllLot.Rows(i)("PRE_COMPLETE_NUM"))
                '枚数
                LastTag.iFrame = Integer.Parse(dtAllLot.Rows(i)("PRE_FRAME_NUM"))
                '不良数
                LastTag.iFailed = Integer.Parse(dtAllLot.Rows(i)("PRE_FAILD_NUM"))
            End If

            '×印数
            LastTag.iCross = Integer.Parse(dtAllLot.Rows(i)("BAD_MARK_NUM"))
            '×印数フレーム
            LastTag.iCrossFrm = Integer.Parse(dtAllLot.Rows(i)("BAD_MARK_FRMNUM"))
            'Qフラグ
            LastTag.fQflag = CBool(dtAllLot.Rows(i)("Q_FLAG").ToString)
            'TESTフラグ
            LastTag.fTestflag = CBool(dtAllLot.Rows(i)("TEST_FLAG").ToString)
            'CHECKフラグ
            LastTag.fCheckflag = CBool(dtAllLot.Rows(i)("CHECK_FLAG").ToString)

            'ステータス
            If dtAllLot.Rows(i)("LOT_STATE") = TagProcessStatus.Ready Then
                LastTag.Status = TagProcessStatus.Processing
            ElseIf dtAllLot.Rows(i)("LOT_STATE") = TagProcessStatus.Processing Then
                If dtAllLot.Rows(i)("COMP_TYPE").ToString.Equals("2") Then
                    LastTag.Status = TagProcessStatus.ManufComplete
                Else
                    LastTag.Status = TagProcessStatus.Ready
                End If
            Else
                LastTag.Status = TagProcessStatus.Ready
            End If
            ' >> 2018/02/08 佐川
            'ラックケースNo
            LastTag.container1 = dtAllLot.Rows(i)("RACK_NO_1")
            LastTag.container2 = dtAllLot.Rows(i)("RACK_NO_2")
            LastTag.container3 = dtAllLot.Rows(i)("RACK_NO_3")
            LastTag.container4 = dtAllLot.Rows(i)("RACK_NO_4")
            LastTag.container5 = dtAllLot.Rows(i)("RACK_NO_5")
            ' << 2018/02/08 佐川

            '>> 2018/7/19 佐川 ベーク工程不良入力
            '子画面で設定した不良数を保存する
            LastTag.iFrame = dtAllLot.Rows(i)("FRAME_NUM")
            LastTag.iCross = dtAllLot.Rows(i)("BAD_MARK_NUM")
            LastTag.iCrossFrm = dtAllLot.Rows(i)("BAD_MARK_FRMNUM")
            LastTag.emptyChipNum = dtAllLot.Rows(i)("EMPTY_CHIP_NUM")
            '<< 2018/7/19 佐川 ベーク工程不良入力

            IcTag = LastTag
            TagWriteBack(LastTag)

        Next
        Return result
    End Function

    Public Sub saveScreen()
        dtDBUpd.Rows.Clear()
        Dim lotCnt As Integer = 1
        Dim drDB As DataRow
        With dtAllLot
            For Each drLot As DataRow In .Rows
                drDB = dtDBUpd.NewRow
                drDB(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = "LOT"
                drDB(DB_WORK_RESULT_PHYSICALNAME_SEQ) = lotCnt
                drDB(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = "1"
                drDB(DB_WORK_RESULT_PHYSICALNAME_LIMIT_TIME) = drLot("LOT_NO")

                dtDBUpd.Rows.Add(drDB)
                lotCnt += 1
            Next
        End With
        '>> 2018/2/26 佐川 仕掛情報保存先変更
        'm_cEquipMat.SaveScrean(g_EQUIP_NO, m_szProc, "0", m_szTable, dtDBUpd) 'UPD 苗 2018/1/19 装置No.の対応
        m_cEquipMat.SaveScreanWorking(g_EQUIP_NO, m_szProc, dtDBUpd) 'UPD 苗 2018/1/19 装置No.の対応
        '<< 2018/2/26 佐川 仕掛情報保存先変更
    End Sub

    Public Sub saveCompScreen()
        '>> 2018/2/26 佐川 仕掛情報保存先変更
        dtDBUpd.Rows.Clear()
        'Dim lotCnt As Integer = 1
        'Dim drDB As DataRow
        'If dtScreen.Rows.Count = 0 Then
        '    dtScreen = m_cEquipMat.GetDetailResult(g_EQUIP_NO, m_szProc, "0", m_szTable) 'UPD 苗 2018/1/19 装置No.の対応
        'End If
        'For Each drLot As DataRow In dtScreen.Rows
        '    drDB = dtDBUpd.NewRow
        '    drDB(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = "LOT"
        '    drDB(DB_WORK_RESULT_PHYSICALNAME_SEQ) = lotCnt
        '    drDB(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = "0"
        '    drDB(DB_WORK_RESULT_PHYSICALNAME_LIMIT_TIME) = String.Empty

        '    dtDBUpd.Rows.Add(drDB)
        '    lotCnt += 1
        'Next
        'm_cEquipMat.SaveScrean(lblEquipID.Text, m_szProc, "0", m_szTable, dtDBUpd)
        m_cEquipMat.saveCompScreen(g_EQUIP_NO, m_szProc) 'UPD 苗 2018/1/19 装置No.の対応
        '<< 2018/2/26 佐川 仕掛情報保存先変更
        dtScreen.Clear()
    End Sub

    Private Sub loadScreen()
        '>> 2018/2/26 佐川 仕掛情報保存先変更
        'dtScreen = m_cEquipMat.GetDetailResult(g_EQUIP_NO, m_szProc, "0", m_szTable) 'UPD 苗 2018/1/19 装置No.の対応
        dtScreen = m_cEquipMat.GetDetailResultDbBake(g_EQUIP_NO, m_szProc)
        If dtScreen.Rows.Count <= 0 Then
            InputDataLotClear()
            Exit Sub
        End If
        Dim index As Integer = 0

        For Each drDB As DataRow In dtScreen.Rows
            If Not IsNumeric(drDB(SEQ_NO)) Then
                Continue For
            End If
            If String.IsNullOrEmpty(drDB(LOT_NO)) Then
                Continue For
            End If
            txtLotNo.Text = drDB(LOT_NO)
            txtLot.Text = drDB(LOT_NO)

            '設備条件を取得する
            Dim equipData = m_cEquipMat.GetEquipResult(drDB(LOT_NO), m_szProc, "1", m_szTable)

            For Each data As DataRow In equipData.Rows
                If data(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG).Equals(txtDbBakeEquipment.Tag) Then
                    txtDbBakeEquipment.Text = data(ACTUAL_MODEL)
                    Exit For
                End If
            Next

            '時間を初期化
            getDbBakeEquipment()
            txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))

            '追加処理起動
            btnAddLotNoAdd()

            btnAry(index).Text = drDB(LOT_NO) + vbNewLine + preRackCaseNo
            txtLotNo.Text = String.Empty
            txtLot.Text = String.Empty
            index += 1
        Next
        '<< 2018/2/26 佐川 仕掛情報保存先変更
        '>> 2018/2/26 佐川 着工中はロット追加不可に修正
        btnLot.Enabled = False
        txtLot.Enabled = False
        txtLot.BackColor = NORMAL_INIT_COLOR
        '<< 2018/2/26 佐川 着工中はロット追加不可に修正
    End Sub

    Protected Sub lotEmptyCheck()
        For Each dtLot In dtAllLot.Rows
            If dtLot("LOT_NO").ToString.Length > 0 Then
                Exit Sub
            End If
        Next

        '組立ロットNo.1～24がすべて空の場合、画面初期化
        InputDataClear()
        LastTag = Nothing

    End Sub

    Protected Function chkPreRackNo(ByVal rackData As DataTable, ByVal lotNoCnt As Integer, ByVal rackNoCnt As Integer, ByVal count As Integer, preRackArray() As String) As Boolean
        '前工程一致チェックを行う
        Dim rackNo As String = rackData.Rows(lotNoCnt)("RACK_NO_" + rackNoCnt.ToString).ToString
        'ラックNoが削除ラックNoと一致する場合、前工程一致チェックを行わない
        If DELETE_RACK_NO.Equals(rackNo) Then
            Return True
        End If
        For i = 1 To count
            'Dim preRackNo As String = rackData.Rows(lotNoCnt)("PRE_RACK_NO_" + i.ToString).ToString
            If rackNo.Equals(preRackArray(i - 1)) Then
                Return True
            End If
        Next
        Return False
    End Function

    Protected Function chkDelRackNo(ByVal rackData As DataTable, ByVal lotNoCnt As Integer) As Boolean
        'ラックNoがすべて削除ラックNoの場合、エラーとする
        Dim compRackNoData = {"", "", "", "", ""}
        Dim rackNum As Integer = 0
        Dim delRackNum As Integer = 0

        'ラックNoを配列に格納
        For i = 1 To 5
            compRackNoData(i - 1) = rackData.Rows(lotNoCnt)("RACK_NO_" + i.ToString).ToString
            If compRackNoData(i - 1).Length > 0 Then
                rackNum += 1
            End If

        Next
        'ラックNoが削除ラックNoの場合、件数をカウント
        For j = 1 To compRackNoData.Length
            If DELETE_RACK_NO.Equals(compRackNoData(j - 1)) Then
                delRackNum += 1
            End If
        Next
        'すべてのラックNoが削除ラックNoの場合、Falseを返却
        If rackNum = delRackNum Then
            Return False
        End If
        Return True
    End Function

    '組立ロットNo.キープレス処理
    Public Sub txtLot_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

        '装置条件の値チェック
        If bakeEquipFlg Then
            If btnStart.Text = getMsgStr("MSG00126") Or btnStart.Text = getMsgStr("MSG00118") Then 'UPD 苗 2018/1/16
                '着工準備
                txtLotNo_KeyPress(sender, e)
            Else
                '着工中
                bakeTxtLot_KeyPress(sender, e)
            End If

            '改行コードが入力された場合
            If e.KeyChar = vbCr Then
                'データ登録を行う
                btnAddLotNoAdd()
                txtLot.Enabled = True
                txtLot.Focus()
            End If

        Else
            MsgBox(getMsgStr("MSG00018", lblDbBakeEquipment.Text))
            'txtDbBakeEquipment.Focus()
            'txtDbBakeEquipment.SelectAll()
        End If

    End Sub

    '組立ロットNo.バーコード入力処理
    Protected Sub bakeTxtLot_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then
            PutLog(btnOptNoStt.ToString, txtOptNoStt.Text, "組立ロットＮｏ．")

            Dim txtOptor As TextBox = CType(sender, TextBox)
            txtOptor.BackColor = Color.Yellow
            txtOptor.Enabled = False

            'ロットNo 画面存在チェック
            If checkScreenLot(txtOptor) Then 'UPD 苗 2018/1/16
                MsgBox(getMsgStr("MSG00089", btnLot.Text))
                txtOptor.BackColor = ERROR_INIT_COLOR
            Else
                txtOptor.BackColor = NORMAL_INIT_COLOR
            End If
        End If
    End Sub

    'ロットNo 画面存在チェック
    Private Function checkScreenLot(txtLot As TextBox) As Boolean
        For i = 0 To 23
            Dim btnLotNo As Button = txtLot.Parent.Controls.Find(String.Format("btnLotDetail{0}", i + 1), False)(0)

            'ボタンが未設定
            If btnLotNo.Enabled = False Then
                Continue For
            End If

            Dim stArrayData() As String = Split(btnLotNo.Text, vbCrLf)
            Dim btnLot As String = stArrayData(0)

            If btnLot = txtLot.Text Then
                Return True
                Exit For
            End If
        Next
        Return False
    End Function


    '装置条件フォーカス処理
    Protected Sub txtDbBakeEquipment_Focus(ByVal sender As Object, ByVal e As System.EventArgs)
        txtDbBakeEquipment.BackColor = Color.Cyan
        txtDbBakeEquipment.SelectAll()
    End Sub


    '装置条件キープレス処理
    Public Sub txtDbBakeEquipment_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

        '改行コードが入力された場合は温度、時間を取得し画面に表示する。
        If e.KeyChar = vbCr Then
            getDbBakeEquipment()
        End If
    End Sub

    '設備条件情報取得処理
    Public Sub getDbBakeEquipment()
        Dim equipment As String
        equipment = txtDbBakeEquipment.Text

        If Not equipment.Equals("") Then
            '設備条件の取得
            Dim dtEquipmentCondition As DataTable = m_cEquipMat.GetEquipmentCondition(lblProcessCD.Text, equipment)
            If dtEquipmentCondition.Rows.Count > 0 Then
                '設備のセットアップ情報に存在する場合は、画面に値を設定する
                txtDbBakeTemp.Text = dtEquipmentCondition.Rows(0)("BAKE_TEMPERATURE")
                txtDbBakeTime.Text = dtEquipmentCondition.Rows(0)("BAKE_TIME")
                'ADD 苗 2018/1/17 BEGIN 
                If txtDbBakeTime.Text.Contains("±") Then
                    Dim stArrayData() As String = Split(txtDbBakeTime.Text, "±")
                    bakeTime = CDbl(stArrayData(0))
                Else
                    Double.TryParse(reg.Replace(txtDbBakeTime.Text, ""), bakeTime)
                End If
                'ADD 苗 2018/1/17 BEGIN 
                'Double.TryParse(reg.Replace(txtDbBakeTime.Text, ""), bakeTime)'DEL 苗 2018/1/17 
                bakeEquipFlg = True
                txtDbBakeEquipment.BackColor = NORMAL_INIT_COLOR
            Else
                MsgBox(getMsgStr("MSG00048", lblDbBakeEquipment.Text))
                txtDbBakeEquipment.BackColor = FOCUS_INIT_COLOR
                txtDbBakeEquipment.Focus()
                txtDbBakeEquipment.SelectAll()
                '温度を初期化
                txtDbBakeTemp.Text = ""
                '時間を初期化
                txtDbBakeTime.Text = ""
                bakeEquipFlg = False
            End If
        Else
            '設備条件に値が入力されていない場合
            MsgBox(getMsgStr("MSG00020", lblDbBakeEquipment.Text))
            txtDbBakeEquipment.BackColor = FOCUS_INIT_COLOR
            txtDbBakeEquipment.Focus()
            txtDbBakeEquipment.SelectAll()
            '温度を初期化
            txtDbBakeTemp.Text = ""
            '時間を初期化
            txtDbBakeTime.Text = ""
            bakeEquipFlg = False
        End If
    End Sub

    '情報タブの組立KeyNoタブキー対応
    Private Sub txtLot_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) Handles txtLot.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            txtLot_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub

    '装置条件タブキー対応
    Private Sub txtDbBakeEquipment_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) Handles txtDbBakeEquipment.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            txtDbBakeEquipment_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub

End Class
